/*
 * jackOlantern.c
 *
 * Created: 9/15/2013 11:08:20 PM
 *  Author: Tim
 */ 
#include <stdlib.h>
#include "../src/Epiphany.h" 

void setup()
{
	clockInit();
	
	TCE0.PER = 1024;
	TCE0.CTRLA = TC_CLKSEL_DIV1_gc;
	TCE0.CTRLB = TC0_CCDEN_bm | TC_WGMODE_SS_gc;
	
	RTC_DelayInit();
	
	adcInit();
	
	PORTE.DIRSET = 0x8;

	sei();
	_delay_ms(100);
	
	srand(analogRead(0));
	RTC_Delay_ms(rand() & 0x0FF);

}
	
void loop()
{
	
	if(delayOver)
	{
		TCE0.CCD = (rand() & 0x3FF);
		
		srand(analogRead(0));
		RTC_Delay_ms(rand() & 0x0EF);
	}
	
}	